created separate method for value validation