modularizing code for final product