added flexible mode