fix problem in plotting phase
updated code to fix plotting phase problem, doesn't work