improve images insert functionality