Got dictionary based approach working
minor changes to dictionary based stuff