ex4-4 refactor