Added code to construct entities