fixed extend function to work as deep extend properly