added more code to support logging in