restructured, only accepts valid coordinates