bugs fixed in naive version