Refactored fix.

According to holygeek's suggestion.