fixed bugs and added minor functionality