edited implementation