Adding all the logic with models