updated to work better interactively