fixed formating, improved code