hotfix: check for begin end before pop