bounds checking added to improve the evaluation on edge conditions / outside of bounds