patch from andrew nile,thx