refactored problems 1-10