some code refacto