implemented flex calc part.