Changed structure from class based to function based