Removed large block of accidentally duplicate code