bug fix and simplify for LBP