added model logic and unit tests