[Lab 3] implemented main functionality