code cleanup and minor change