Debug and refactorising