Clarify some code by extracting methods