updated code to handle additional at-bat events