Splittet out actual logic from debug code