refactored, made modules and test cases