Added some logic in models