added some variable validation