Finalizing function and ternary