fix from http://stackoverflow.com/a/27530676/270197