refactored all the conditional statemnets out of the view