More modularized version