cleaned up model code