little modification on location sql