Introducing a express server and refactoring code