Minified the logic to be better.