refactored code to minimize repeated operation sin fastlda