cleaned up validation, used more functions