dict based solution