Added bugfix from John