bug fixes and added function to handle gps error