noraesae's patch for issue 34, great thanks to  noraesae & zhs490770