bugfix and improvement