Changed if to else if

According to @tomer's suggestion.