Fixed issue with calculation
Re-added try catch in checkLength to stop exceptions being thrown