updated databsae / entity logic