Fixing the usage of ternary operator in model which caused Empty Query error.