First working version without any optimization