encrypt refactor