More efficient GPS code