Finished off login functionality