Optimizing the integration of a statistical language model in HMM based offline handwritten text recognition