adding exception handling in printSpikes()