refactoring showResult func