implement beam search (not enabled as default)