added model query code, updating tests