extracted out method to assert for valid name