added extra conditions & secured variables