Validate input

line 277 fails if imput is not proper