refinement and bugfix