Tried @rougier's suggestion to fix the bug.

Fix #252. Waiting for Travis.