refactor with attribute trait