fork and modify a little to work on my machine