removed unused code and added comments