Updated for consistency with code from video