avoid duplicate code bugs and better logging