added comments, extracted anonymous classes and now only save rating data when there are no errors from validation