create and degbugged each piece of code