Why is this if all around the code when it only changes a small part?