Replace ternary operator with regular if else to support python 2.6