Adding a little branching logic to help prevent errors