refactoring print stack trace