separated out repetitive code into a function
Modified variable naming, constant regex for time
Added exception handling
added rescue exception