fixed bugs, improved formatting