improved entity class and fixed bug