refactored tries function and added best time