gradient added, test program updated