added intermidiate functions