refactor and coverage test problem 1