refactored into lib and added composer file