fixed logic for passing data to view