Implemented function to insert at a position