refactor with maps