Is there anything wrong in my logic? please help.