Added comments and removed useless code