Simplify and fix code to determine whether what to create