Moved security check to top of page