Added input handling