moved some functions to external module