Added logic for tableview and modified master controller