convert to function-based calculations