Added some code for generating metadata