cleaned up dictionary code a little