added some optimization
metropolis in seperate module
metropolis in a seperate module