fixed results logic and moved it into a model