Made changes to the logic to remove time out occuring because of unnecessary computations