refactored and shaped up the library