Refectored vision code