working print function