moved methods from r file to utils