modified code for login and posts