added comments and removed useless variables