apply re-implemented. not tested yet