Replacing duplicate checking logic with non "Cloud Code" verison

I think beforeSave is available for Parse's "Cloud Code" only, which is
why there's an error when trying to use it. I've replaced the logic with
a more basic duplicate check