Code is refactored
Comments are added