use already defined extend function instead of recreating it