Refactored JS and added CSS