Q5: more bug fixing