added better error output if invalid data submited