Refactoring the some code under 'lib'