Location fetching

code cleanup and merge with location fetching