finished validate function