Use vectors to simplify array code