added ignore file
moved functions outside of main() with some clean-up