refactoring fun lib