added some real code
fixed bug 10012
cleanup the code a bit