define commonly used function and use global variable.
use 'try,except' cuz you don't know how many test on it.