Added error code handling to loginswitch