working module with refactoring