Renamed file and factored out logic