speed up and serious bug fix