Moved code to a separate method