added complicated reduce functions, may break build