more refactoring
simplify JS