fixed first bug; some stilistic changes