adding error handling to GPS code