(Malim or mualim refers to the pious local Muslim community)

In the early AD 1700, a Bugis settlement was established along the riverbank of Sungai Bernam, as part of Raja Kecil's plan to set up one of its "kubu," fort along the river to fend off the northern Perak Sultanate threat.