refactoring of code - rachit