this took a lot of time.