added documentation and fixed "null" being printed