added required var check for better error messages (=avoid nullpointer exceptions ;-))