Avoid code repetition [ci skip], thanks @vezzi!