refatoring of create and remove functions