Fixed bug with entities