main functionality fixed