First shot at modularizing code