fixed bad syntax, removed duplicate code