Updated code

Fixed #703