refactored code to be more decoupled, more testable, more efficient, more compact, and also added the second half of the video tutorial