Fixed invalid use after scope