cleaner variable check and passing

Made the variable check a bit more performant and cleaner.