modularize crwal logic.