updated ror function