changes for direction to accept range parameters as well, and a bug fix
merge