Add working implementation. Delete legacy code