move utils functions to lib