Moved view creation to the top.