Maybe get rid of the ternary operator and use a cast here?