Code implemented attempt 2