Fixed bug: close cursor problem