minor internal changes to make it more efficient/encapsulated

changed this to variables scope and changed the way data is stored to be
more efficient