Put main loop into main() function as new-detail option was not working correctly. Less codey, more worky.