wrap up direction check in a inline function