fix cursor routine