Fixing error when executing twice