Replaced class by for-loops