add extra condition to first if statment
refactor solve_for_three using number instead of first element