Full implementation with all tests passing