re-factoring Auto login implementation.