Debugged version ready for testing