add problem #8 + refactoring for multiple input types