Modified solution_22 and solution_23 for #22 and #24