make the input handling a bit more robust