link shows how to add element at cursor.
Moved adding logic out to a service
and now with the check in Moved logic to service