Solved problem with opened cursors