Simplify logic using a proper function as spotted by Ermal