improving location records script
separating sql execute