tidy views, improve logic code