rewrite with es6