fixed api_error bugs and split switch in two