moved code from index to app