Refactored problems 21, 22, 24 & 25