refactor to split up responsibilities