updated pig analysis script