Refactored problems 10 and 11