fixed plotting algrithem.