Remove debug information
Refacotr common logic