debugged version