new code update with reworked collision