optimized orderedForm function, need to test
added more test program