add -u flag, refactor