refactored: two functions; updated comments