bug correction and optimissation