refactoring and fixed the time format bug for showing hours