functions for getting location info and code optimization