finish direction part

also finish while part, next is to think about how to add sum part into
it