improvement and bug fixes