Tighten up the if else to avoid duplication