implement and fix bug