Changes implemented

1. Used classList.add() method to assign class to a element.
2. optimised the code.