Chaining the base onsubmit.

and polished some codes.