This looks like a lot of code. Is it copied from somewhere else? Can you refactor it if that is the case?