Edited implementation.