Common functions used for data processing