refactor with methods