code refactoring for session timeout