add opts and multithreading