Added comments and removed unnesesary code