Fixed bug which gave an undefined error for r

Signed-off-by: Juan Rodriguez <juanrodriguez@test.com>