classify most  of the code and some cleaning