made code much more modularized YAY