added phaseB logic in comments
resolved merge conflicts