added auxiliary fuction ec