Made messages() more flexible