switched simpler implementation using lists