Issue #7 : Handle nested objects with depth one correctly

Addressed issue#7

Improvements : Turn it into a recursive routine to handle arbitrarily deep nested objects