Refactored to a lib folder