refactored context timeout checking