Calculate path