modularized a bit