refactored + added overlap checking