added inc handler and code cleanup