made print and read into functions