formatting and modularizing