i did a few tweaks. code is now easier to read