improve coordinate checking