code cleanup and doc added