updating and cleaning up prune_model function