better input data checking