bug fix for regression and add encoder