Refactor code for ARC