moved some useful methods from demo to B2DEntity class