updated spatial code