Removed some unnecessary code and added comments