formated codes and added parts from other files