refactoring: minor code reduce and each class into a separate file