Fix bug in backspace prevention code