put cap calculation into viewWillApper