fix bugs with errors