the final version for demo

our last minute bug squashing for the main function and other functions