rewritten entire system