still doesn't work, a few bug fixes