refactor user action code