Main functionality now working