changed some views code to a helper