refactered code

refactered code