refactoring code plus fixing coding style issues

Signed-off-by: Smita Kumari <kumarismita62@gmail.com>