Replace usage of err function