adding the logic