changed some debug messages...now uses foreach