Improve input handling