Refactored FLW code