adding err function