Delete debug log and Refactor code