main functionailty complete