added login function that checks credentials