Fixing condition to check for id existence