reordered if statement to be a bit more straightforward (in my eyes), then replaced the DB-based checks with session data checks.