Fixed for issue#318, Incorporated review comments