working version with step scope function in bi-directions