Debugged recursive ack function