add checks to avoid errors when empty/short stack trace