Changed class name and method name, variable name ($messages) corrected.