clean up of logic