Change if else at end into a ternary

exactly what the title says