Refactored architecture & implemented use of sorted values