added getMessages() & refactoring