Added immutability and converted to case classes