fixed something but now it has errors on xmin xmax