Fix the logic which is not working