Fixed a bug, but quite slow right now