How to use reference instead of printing attribute