Move view index code to seperate file