working but before cleaning the code