Started validate function

other minnor changes