added code from GPS 1.1