better handle of reset. code cleanup