more robust input handling