Checking in better python logic