added improved fix for issue 186