add better error handling, remove redundant address computation