pig logic added