refactor CSS and JavaScript to adhere to DRY principles