code reorganisation
final state