Duplicate code here, refactor.