Moved model building to a separate model