my first guess would be that the functions defined before the setup() should probably be in at the end of the loop().