fix one line bug and simplify some stuff