Made necessary variables extern