implement print_top function