helper method for validation