improving analysis code