very slow!! debugged version