again refactored code,works!!!