dp logic clean up