Code for testing purpose.Will work on old db structure.