move helper methods to lib