fix crashing issue, cursor outside bounds