adopted functions from apache.common.lang3