validate inputs more robustly
[bug fixed] validation of inputs