logic clean up