add direction variable into metropolis method