refactoring basic library code