invalid input handling added