re-structured

 I have  re written the ternary for correct results test