refactor year to string while loops to blocks