seems like this if could be refactored to remove the nested if and then the else would no longer be needed