Modified version that doesn't use re