Logic improvements