add the $parent in the extend function
adding some comments