Added multiple side detection support