added rdiff for function but not fully working