working version of createEntity