Fixing issue #70 - Running code before redirect not working

Please look if this solution will suffice. It is working properly.