Changed around the login, added checks to see if permissions where right