refactor helper functions into impl ns