checking whether a block of code is being executed