refacotring a little bit