changed some simple logic