fix type error
simplify code