Quite a bit of B Logic here, at best it should be in a service… at worst it should be in a private method