update main with free function