fixed error coments and cleaned up code