Refactored code - more effecient memory usage, more readable code