re-factored code and cleaned up class variables