works for all cases- exceeds time though