Make calculation of source location more robust