Optimized code for reverse address ruby app (reviewed by Gaurav).