fix entity code