moved prep logic