Shortened a bit and fixed a bug