Code rewritten, class made to IEnumerable