Fixed extend function