cleaned legacy code