Moved logic from index to application class