Added logic for rebounding