Fix bug that caused multiple blocks to be executed