validate inputs, fix #1