change insertBefore function to before and add after