Further implemented flex calculation algorithm.
extracted flex logic into different class.