added conditional for input validation