I think it would be easier to read if we had explict if statements here - can you simplify it?