added some location checking