fixed issues with try catch not working: missing a curly brace to close the try and if correctly