refacotred JS