fix memory usage
fix indentation