made code better looking.
fixed bug pointed out by djuber.