added beam pruning to the decoding function