Refactored arrow code