added printf and some misc code