Add withTimeout function