Fixed memory access violation in Pierrick's implementation