logic cleanup