updating formating and made loops more advanced