Converted to ARC
Refactored the code