Fixed access violation bug