added printing and fixing some issues