refactor main file for handwritten digits recognition