Made code changes to work with returning BaseEntity