Minor fix: changed if to else-if statements