Pulled definition of r/a out into seperate function/