MOdified the update entity function to work