switch account function cleaned/deugged