Any reason for this temporary variable? If not you could combine the two if conditions into one.