Added logic to main