fix z sorting