this is totally duplicated, so i should probably put it in a service.