added a better solution