main function troubleshooting, still needs some work to get final answer