code cleanup for optimization