fixed flag error checking, and no longer need to pass ls in