bugfix and improving design