code rewrite with better swob support