More variable checking added for @bradwiatr