now cut some functions and clean some code