Simplified the last change a little using a fix derived from