code reorg + added support for more than 2 or + brought macro in it