clearMessages functioning