some code improvements for karma