printf caused delay in printing; fixed