modified print function