Refactoring js code and creating a separate style file