Use to_atoms instead of unpacking struct