added some postgis magic