refactor and clean up extraneous code
fix elapsed time check