gradient computation added for parallel LSS