got input to control cursor index correctly