Main functionality implemented