fixed the bug with elements deletion