modularized a little bit