refactored message listing, cleaned up code formatting