with optimizations and ncurses