removed unnecessary comments and restructured code