better errors, code deduplication