added location detection

has memory leak