rewritting to CS by Zibby