refactored file structure and server side logic