Added comments and removed unused function