added function comments & refactored elapsed_time