add login and register logic