Commented and changed the code