Refactored to use module and more objects
more refactorings