Addede Entity. Tidied up code a bit