try/catch instead of broken if statement