some code refacotring