Refactor unpacking