Reviewed Bryan's code and made some corrections