refactored by making a toInt method instead of Integer.parseInt()