refactored course/lab collision to a single function