bug fixing, removed legacy code