Simplify logic by using the appropriate functions.