original version of Joshs code that include search over sky location