Refactoring the library for proper reusability