improve and fix bugs