refactored #3
refactored #9
problem 20