using FSR, also added pseudo main code