moved some functions to common lib