minor code cleanup and improvement