Made print function more modular