Modularize the code