Fixed error, added entity check