javascript: better print function