another go at the logic