modularize the code to make it more extensible