refactor cap