Extracting some methods to make flow more understandable