Using python dictionaries instead of if and elif