Simplified the extend function