refactor address checking