changed order of definition and binding of handlers