fixed issue 1249, thanks Alan