added more image analysis code