removed unnecessary code and added comments