Refactor parseTime method