Fixed bug on update_count function