fixes memory error