fix bugs and types