moved some logic from index to main