Cleaned up inRange function and added its proper function header