Removed duplicates from list, cleaned up code