moved some functions to external files