which is the best way to solve this problem?