adapted to pullrequest #28 on original repo