fix code complexity issues