Refactoring Javascript and CSS