fixed the fourpats function