why is there a duplicate `if` here?