Removed try/catch blocks and added compatibility with other browsers