In reply to Leonid Batkhan.

Leonid, thank you very much. Now the code is working as expected.