Wrote checkLogin function