Refactor class Solution1