Location detection code added