extracted  + few adjustments