Better emulation of $.extend