Added functionality to the SetEntity Function