cleaned up validation logic