Fix value check, remove debug code