extracting working. TODO1: spaces should not be ignored, TODO2: specify when to exit