Refactoring and few bug fixes

Signed-off-by: rachitmishra <twntee@gmail.com>