Merged Cameron's heat seeking code with modifications