a couple of small fixes for the main function