fixed logic issues in models