refactor with resources manager