Added ratio detection and ensured we do not get a divide by zero error. Made getting information from the rect a function.