code cleaning
decoupling the code a bit