Refactoring post logic
refactoring login logic