trys added and non-needed code removed