Improving Time Complexity