refactor to support trusty