made structural changes and fixed 'login' state issue