Implement Main logic