Get rid of some duplications
Code refinment