fix js bug on validation when a newer pattern is found in db