finish refacotring code