remove left over end statement
replace ternary operation with functions