Fixing tmp logic