comments and removal of duplicate functions