added some improvements after watching the solution video