removed some duplicate code
cleaning up login