Turn if statement to be more pythonic