getting the logic working