most of the input validation done