Main functionality done