Changed login to query in db