Factoring out duplicate code to before