refactored handling fp error