implemented some of the logic we discussed at the meeting