Ok, now that I think about it, targetWidth and targetHeight may not have been set... I still don't think you should need to have this calculation repeated in 2 places after a little refactoring.