imports optimized; api error check deepened