four modes implemented
final modification