finished refactoring after watching videos