fixing cursor out of bounds bugs