bugfix in substring